﻿using QH.JobBack.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace QG.JobBack.DAL
{
    public interface IRepository<T>where T : class
    {
        /// <summary>
        /// 通用新增方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Add(T entity);

        /// <summary>
        /// 通用删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Delete(T entity);


        /// <summary>
        /// 通用批量删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Delete(List<T> entitys);

        /// <summary>
        /// 通用批量删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Delete(params int[] ids);


        /// <summary>
        /// 通用修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Update(T entity);


        /// <summary>
        /// 通用查询集合
        /// </summary>
         List<T> QueryList(Expression<Func<T, bool>> expression = null);


        /// <summary>
        /// 查询返回对象
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
         T Query(Expression<Func<T, bool>> expression = null);


        /// <summary>
        /// 判断记录是否存在
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
         bool Exists(Expression<Func<T, bool>> expression = null);


        /// <summary>
        /// 分页查询
        /// </summary>
        /// <returns></returns>
         List<T> QueryPageList<S>(int pageIndex, int pageSize, Expression<Func<T, bool>> whereExpression, Expression<Func<T, S>> orderExpression, bool isDsc = true);


        /// <summary>
        /// 返回总数
        /// </summary>
        /// <param name="whereExpression"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        int GetCount(Expression<Func<T, bool>> whereExpression, out int count);


      
    }
}
